package com.music.service.urls.service;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Required;

import com.music.service.urls.beans.Url;
import com.music.service.urls.dao.UrlDAO;

public class UrlServiceImpl implements UrlService {

	private UrlDAO mUrlDAO;

	@Override
	public List<Url> getUrlsOfSong(Long pSongId) {
		return getUrlDAO().getUrlsOfSong(pSongId);
	}
	
	@Override
	public boolean addNewUrlToSong(Long pMemberId, Long pSongId, String pUrlPath) {
		return getUrlDAO().addNewUrlToSong(pMemberId, pSongId, pUrlPath);
	}

	
	
	/**
	 * @return the urlDAO
	 */
	public UrlDAO getUrlDAO() {
		return mUrlDAO;
	}
	/**
	 * @param pUrlDAO the urlDAO to set
	 */
	@Required
	public void setUrlDAO(UrlDAO pUrlDAO) {
		mUrlDAO = pUrlDAO;
	}

	@Override
	public Map<Long, Url> getUrlsForSongsForMember(Long pMemberId,Long... pSongIds) {
		return getUrlDAO().getUrlsForSongsForMember(pMemberId, pSongIds);
	}
	
	@Override
	public Map<Long, Url> getUrlsForSongsForMember(Long pMemberId,Collection<Long> pSongIds) {
		Long[] songIds = new Long[pSongIds.size()];
		int index = 0;
		for(Long songId:pSongIds){
			songIds[index++]=songId;
		}
		return getUrlDAO().getUrlsForSongsForMember(pMemberId, songIds);
	}
}
